import request from '@/utils/request'

export function getList(params) {
  return request({
    url: '/api/identity/users/extend',
    method: 'get',
    params
  })
}

export function getById(id) {
  return request({
    url: '/api/identity/users/' + id,
    method: 'get'
  })
}

export function create(dto) {
  return request({
    url: '/api/identity/users/extend',
    method: 'post',
    data: dto
  })
}

export function edit(id, dto) {
  return request({
    url: '/api/identity/users/' + id + '/extend',
    method: 'put',
    data: dto
  })
}

export function deleteById(id) {
  return request({
    url: '/api/identity/users/' + id,
    method: 'delete'
  })
}

export function lockUser(id, seconds) {
  return request({
    url: '/api/identity/users/' + id + '/lock/' + seconds,
    method: 'put'
  })
}

export function unlockUser(id) {
  return request({
    url: '/api/identity/users/' + id + '/unlock',
    method: 'put'
  })
}

export function changePassword(id, data) {
  return request({
    url: '/api/identity/users/' + id + '/change-password',
    method: 'put',
    data: data
  })
}

export function getAssignableRoles() {
  return request({
    url: '/api/identity/users/assignable-roles',
    method: 'get'
  })
}

export function getUserRoles(userId) {
  return request({
    url: '/api/identity/users/' + userId + '/roles',
    method: 'get'
  })
}

export function getAssignableOrganizationUnits() {
  return request({
    url: '/api/identity/users/assignable-organization-units',
    method: 'get'
  })
}

export function getOrganizationUnits(userId) {
  return request({
    url: '/api/identity/users/' + userId + '/organization-units',
    method: 'get'
  })
}
